<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2025/3/18
  Time: 16:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <style>
        .demo-reg-container{width: 320px; margin: 21px auto 0;}
        .demo-reg-other .layui-icon{position: relative; display: inline-block; margin: 0 2px; top: 2px; font-size: 26px;}
    </style>
</head>
<body>
<form class="layui-form" action="addDept" method="post">
    <div class="demo-reg-container">

        <div class="layui-form-item">
            <div class="layui-input-wrap">
                <div class="layui-input-prefix">
                    <i class="layui-icon layui-icon-username"></i>
                </div>
                <input type="text" name="dname" value="部门01" lay-verify="required" placeholder="部门名称" autocomplete="off" class="layui-input" lay-affix="clear">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-wrap">
                <div class="layui-input-prefix">
                    <i class="layui-icon layui-icon-password"></i>
                </div>
                <input type="text" name="manager" value="暂无" lay-verify="required" placeholder="部门负责人" autocomplete="off" class="layui-input">
            </div>
        </div>

        <%--   用户的邮箱     --%>
        <div class="layui-form-item">
            <div class="layui-input-wrap">
                <div class="layui-input-prefix">
                    <i class="layui-icon layui-icon-email"></i>
                </div>
                <input type="text" name="num" value="0" lay-verify="required" placeholder="部门人数" autocomplete="off" class="layui-input" lay-affix="clear">
            </div>
        </div>

        <%--   用户的出生年月日     --%>
        <div class="layui-form-item">
            <div class="layui-input-wrap">
                <div class="layui-input-prefix">
                    <i class="layui-icon layui-icon-date"></i>
                </div>
                <input type="text" name="createtime" id="date" lay-verify="required|date" placeholder="部门成立时间" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-reg">保存</button>
        </div>
    </div>
</form>


<%--引入外部js--%>
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(function(){
        var $ = layui.$;
        var form = layui.form;
        var layer = layui.layer;
        var util = layui.util;
        var laydate = layui.laydate;

        // 日期
        laydate.render({
            elem: '#date'
        });

        // 自定义验证规则
        form.verify({

        });

        // 提交事件
        form.on('submit(demo-reg)', function(data){
            // var field = data.field; // 获取表单字段值

            // 显示填写结果，仅作演示用
            // layer.alert(JSON.stringify(field), {
            //     title: '当前填写的字段值'
            // });
            // 此处可执行 Ajax 等操作
            // …
            return true; // false阻止默认 form 跳转
        });
    });
</script>
</body>
</html>
